﻿/*
* Activity Tracking Log v0.1.1 - http://activitytrackinglog.codeplex.com
* Activity Tracking Log for ASP.Net & ASP.Net MVC
* Copyright (c) 2011 Vadim Burac
* Licensed under the Microsoft Public License (Ms-PL)
* http://activitytrackinglog.codeplex.com/license
*/

using System;
using System.Web;
using System.Linq;
using System.Linq.Expressions;
using ActivityTrackingLog.Utils;
using System.Reflection;
using System.Collections.Generic;
using ActivityTrackingLog.Data;
using ActivityTrackingLog.Web.Helpers;
using ActivityTrackingLog.Configuration;
using ActivityTrackingLog.Web.Utils;

namespace ActivityTrackingLog.Web.Handlers
{
    internal class AnalyticsApi : BaseAnalyticsHandler
    {
        protected override string GetContentType()
        {
            return "application/json";
        }

        protected override bool ValidateAccess(HttpContext context)
        {
            return (!Config.Api.LocalOnly || context.Request.IsLocal)
                && Config.Api.Enabled;
        }

        protected override QueryParams GetQueryParams(HttpContext context)
        {
            var qParams = base.GetQueryParams(context);
            // override view type for API since it returns json only
            qParams.ViewType = HtmlHelper.ViewTypeEnum.Data;

            return qParams;
        }
    }
}
